package com.sumainfor.pc.gmio.service.impl;

import com.sumainfor.common.util.JsonResult;
import com.sumainfor.pc.gmio.dao.WorkBenchManageMapper;
import com.sumainfor.pc.gmio.feign.Zfeign.ZpcMktFeign;
import com.sumainfor.pc.gmio.service.WorkBenchManageService;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.collections.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author Eddy·Chen
 * @Email 835033913@qq.com
 * @Create 2019-04-12 19:50
 * 经理和助理工作台
 */
@Service
@Transactional(rollbackFor = Exception.class)
@Log4j2
public class WorkBenchManageServiceImpl implements WorkBenchManageService {

    @Autowired
    private WorkBenchManageMapper mapper;

    @Autowired
    ZpcMktFeign zpcMktFeign;
    /**
    * <p>
    *重要状态提醒
    * </p>
    *
    * @author: zhoucong
    * @since:
    */
    @Override
    public JsonResult importantState(){

        JsonResult result = new JsonResult();
        Map<String,Object> params = new HashMap<>();


        //逾期账单
        params.put("OutOrderAndgInOrderCount",mapper.getInOrderCount()+mapper.getOutOrderCount());
        //强制退租单
        params.put("selectForceOrderCount",mapper.selectForceOrderCount());
        //房源疑问
        params.put("selectHousingQuery",mapper.selectHousingQuery());
        //客诉中心
        params.put("selectComplaint",mapper.selectComplaint());
        //黑名单审核
        JsonResult blaResult = zpcMktFeign.getBla();
        if(blaResult.isSuccess()==true){
            Map<String,Object> blaMap =(Map<String,Object>)blaResult.getResult();
            params.put("tcmktTenantBlaCount",blaMap.get("tcmktTenantBlaCount"));
        }else{
            params.put("tcmktTenantBlaCount",0);
        }
        return result.put(params);
    }

    /**
    * <p>
    * 系统消息提醒
    * </p>
    *
    * @author: zhoucong
    * @since:
    */


    /**
    * <p>
    * 日账单审核
    * </p>
    *
    * @author: zhoucong
    * @since:
    */
    @Override
    public JsonResult dailyBillAudit(){
        JsonResult result = new JsonResult();
        Map<String,Object> params = new HashMap<>();
        Map<String,Object> paramsOne = mapper.getTenantBillListByTenId();
        Map<String,Object> paramsTwo = mapper.getTenantBillListByTenIdNow();
        Double getTenantBillListByTenId =MapUtils.getDouble(paramsOne,"sumOne")+MapUtils.getDouble(paramsOne,"sumTwo");
        Double getTenantBillListByTenIdNow =MapUtils.getDouble(paramsTwo,"sumOneOne")+MapUtils.getDouble(paramsTwo,"sumTwoTwo");
        params.put("getTenantBillListByTenId",getTenantBillListByTenId);
        params.put("getTenantBillListByTenIdNow",getTenantBillListByTenIdNow);
        return result.put(params);
    }

    /**
    * <p>
    * 租客密码发放
    * </p>
    *
    * @author: zhoucong
    * @since:
    */
    //@Override
   // public  JsonResult tenantPasswordDistribution(){
    //JsonResult result = new JsonResult();
    //return result.putFailed("暂时未调用。。。");
   // }

}
